#ifndef VEC4_H
#define VEC4_H

#include "SDL2/SDL.h"

struct Vec4 {
	union {
		struct {
			int x;
			int y;
			int w;
			int h;
		};
		SDL_Rect rect;
	};

	Vec4();
	Vec4(int x, int y, int w, int h);
	Vec4(SDL_Texture *texture);

	inline void move(int x, int y);
	inline void move_inverted(int window_w, int window_h, int x, int y);
	inline void scale(int w, int h);
	inline void scale(float f);
	inline void center_x(int total_w);
	inline void center_y(int total_h);
	inline void center(int total_w, int total_h);
	inline void above_of(Vec4 other, int border);
	inline void below_of(Vec4 other, int border);
	inline void left_of(Vec4 other, int border);
	inline void right_of(Vec4 other, int border);
};

inline void Vec4::move(int x, int y)
{
	this->x = x;
	this->y = y;
}

inline void Vec4::move_inverted(int window_w, int window_h, int x, int y)
{
	this->x = window_w - x - w;
	this->y = window_h - y - h;
}

inline void Vec4::scale(int w, int h)
{
	this->w = w;
	this->h = h;
}

inline void Vec4::scale(float f)
{
	w *= f;
	h *= f;
}

inline void Vec4::center_x(int total_w)
{
	x = total_w / 2 - w / 2;
}

inline void Vec4::center_y(int total_h)
{
	y = total_h / 2 - h / 2;
}

inline void Vec4::center(int total_w, int total_h)
{
	x = total_w / 2 - w / 2;
	y = total_h / 2 - h / 2;
}

inline void Vec4::above_of(Vec4 other, int border)
{

}

inline void Vec4::below_of(Vec4 other, int border)
{
	x = other.x;
	y = other.y + other.h + border;
}

inline void Vec4::left_of(Vec4 other, int border)
{

}

inline void Vec4::right_of(Vec4 other, int border)
{
	x = other.x + other.w + border;
	y = other.y + other.h / 2 - h / 2;
}

#endif